//
//  MPActivityViewController.m
//  MobileProject
//
//  Created by caiqilin on 2017/6/15.
//  Copyright © 2017年 caiqilin. All rights reserved.
//

//#import <BmobSDK/Bmob.h>
#import "MPWebInfoViewCell.h"
#import "MPActivityViewController.h"
#import "SVProgressHUD.h"
#import "MPWebViewController.h"
@interface MPActivityViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, assign) int pageNum;//页码
@property (strong , nonatomic) UITableView *table;
@property (nonatomic, strong) NSArray *infoArray;

@end

@implementation MPActivityViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self initView];
    
//    BmobQuery *bmobQuery = [[BmobQuery alloc] init];
//    NSString *bql = @"select * from sgs_assit_h5_pages where sgs_content_type= ? order by -sgs_create_date";
//    
//    NSArray *placeholderArray = @[@2];
//    [SVProgressHUD showWithStatus:@"正在加载中,请稍后"];
//    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeBlack];
//    [bmobQuery queryInBackgroundWithBQL:bql pvalues:placeholderArray block:^(BQLQueryResult *result, NSError *error) {
//        if (error) {
//            NSLog(@"%@",error);
//            [SVProgressHUD showErrorWithStatus:@"网络异常!"];
//            [SVProgressHUD dismiss];
//        } else {
//            [SVProgressHUD dismiss];
//            if (result) {
//                NSLog(@"%@",result.resultsAry);
//                self.infoArray = result.resultsAry;
//                [self.table reloadData];
//            }
//        }
//    }];
    
}

- (void)initView {
    self.table = [[UITableView alloc] initWithFrame:CGRectMake(0, 40+ 64, SCREEN_WIDTH, SCREEN_HEIGHT -40 - 64) style:UITableViewStyleGrouped];
    self.table.delegate = self;
    self.table.dataSource = self;
    self.table.backgroundColor = [Util stringTOColor:@"#f2f2f2"];
    [self.view addSubview:self.table];
    
    [self.table registerNib:[UINib nibWithNibName:@"MPWebInfoViewCell" bundle:nil] forCellReuseIdentifier:@"MPWebInfoViewCell"];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return self.infoArray.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    MPWebInfoViewCell *orderManageCell = [tableView dequeueReusableCellWithIdentifier:@"MPWebInfoViewCell"];
//    BmobObject *obj = self.infoArray[indexPath.section];
//    orderManageCell.middleLabel.text = [obj objectForKey:@"sgs_content_title"];
//    orderManageCell.rightLabel.text = [obj objectForKey:@"sgs_create_date"];
    
    
    return orderManageCell;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return 80;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//    BmobObject *obj = self.infoArray[indexPath.section];
    MPWebViewController *webView = [[MPWebViewController alloc] init];
//    webView.url = [obj objectForKey:@"sgs_content_url"];
//    webView.navigationItem.title = [obj objectForKey:@"sgs_content_title"];
    [self.navigationController pushViewController:webView animated:YES];
}

@end
